#ifndef AUTHCLIENT_H
#define AUTHCLIENT_H

#include <QObject>
#include <QNetworkReply>
#include <QNetworkAccessManager>
#include <QNetworkRequest>

class AuthClient : public QObject
{
    Q_OBJECT
public:
    explicit AuthClient(QObject *parent = nullptr);
    void requestVerificationCode(const QString &email);
    void registerUser(const QString &email, const QString &password, const QString &code);
    bool loginUser(const QString &email, const QString &password);

signals:
    void codeSent(bool success);
    void registerResult(bool success, const QString &message);
    void loginResult(bool success, const QString &message);

private slots:
    void onCodeReplyFinished(QNetworkReply *reply);
    void onRegisterReplyFinished(QNetworkReply *reply);
    void onLoginReplyFinished(QNetworkReply *reply);

private:
    QNetworkAccessManager *m_manager;
    const QString SERVER_URL = "http://localhost:5000";
};

#endif // AUTHCLIENT_H
